package com.huobao.yunying.activitys;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.entity.Sixin;
import com.huobao.yunying.entity.UserInfo;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

public class Act_Sixin extends HuobaoBaseActivity {

	private int m_CurrentPage = 1;

	@Override
	protected int getContentView() {
		return R.layout.layout_sixin_list;
	}

	@Override
	protected String getTitleText() {
		return "私信消息记录";
	}

	@Override
	protected void init() {
		getData();
	}

	private void getData() {
		Map<String, String> map = HttpUtil.getParams("app", "message", "act", "privatepm", "page", m_CurrentPage + "");
		Http.getInstant().sendRequest(context, map, new HttpListener() {

			@Override
			public void onHttpSuccess(String result) {
				JSONObject jsonObject = JSON.parseObject(result);
				JSONArray array = jsonObject.getJSONArray("retval");
				List<Sixin> list = new ArrayList<Sixin>();
				for(int i=0;i<array.size();i++){
					JSONObject object = array.getJSONObject(i);
					Sixin sixin = JSON.parseObject(object.toString(), Sixin.class);
					UserInfo userInfo = JSON.parseObject(object.getString("user_info"), UserInfo.class);
					sixin.user_info = userInfo;
					list.add(sixin);
				}
			}

			@Override
			public void onHttpError(String error) {
				// TODO Auto-generated method stub

			}
		});
	}
}
